<html>

<head>
<title>Classes: Global</title>
<style type="text/css"><!--tt { font-size: 10pt } pre { font-size: 10pt }--></style>
</head>

<body bgcolor="#ffffff" text="#000000" link="#000080" vlink="#800000" alink="#0000ff">

<table border="0" cellpadding="0" cellspacing="0" bgcolor="#d0d0d0">
  <tr>
    <td width="120" align="left"><a href="framebuf.html"><img width="96" height="20"
    border="0" src="../images/navlt.gif" alt="FrameBufferHandler"></a></td>
    <td width="96" align="left"><a href="imgfilt.html"><img width="64" height="20" border="0"
    src="../images/navrt.gif" alt="ImageFilterHandler"></a></td>
    <td width="96" align="left"><a href="../classes.html"><img width="56" height="20"
    border="0" src="../images/navup.gif" alt="Classes"></a></td>
    <td width="288" align="right"><a href="../index.html"><img width="230" height="20"
    border="0" src="../images/proglw.gif" alt="Table of Contents"></a></td>
  </tr>
</table>

<table border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="600"><br>
    <h3>Global</h3>
    <p><small><strong>Availability</strong>&nbsp; LightWave 6.0</small><br>
    <small><strong>Component</strong>&nbsp; Layout, Modeler</small><br>
    <small><strong>Header</strong>&nbsp; <a href="../../include/lwglobsrv.h">lwglobsrv.h</a></small></p>
    <p>Global class plug-ins provide services that other plug-ins can use. They extend the
    list of <a href="../globals.html">globals</a> that are part of the plug-in API.</p>
    <p>Other plug-ins call your global class plug-in by calling the GlobalFunc with your
    server name as the first argument. LightWave calls your activation function, which fills
    in the <tt>local-&gt;data</tt> field. This is then passed back to the caller as the return
    value of the GlobalFunc call.</p>
    <p><strong>Activation Function</strong></p>
    <p>The <tt>local</tt> argument to a global's activation function is an LWGlobalService.</p>
    <pre>   typedef struct st_LWGlobalService {
      const char *<strong>id</strong>;
      void       *<strong>data</strong>;
   } LWGlobalService;</pre>
    <dl>
      <dt><tt><strong>id</strong></tt></dt>
      <dd>The server name. This will be the same as the <tt>name</tt> field of the plug-in's <a
        href="../server.html">server record</a>. It's also the string that the requesting plug-in
        passed as the first argument to the GlobalFunc. If the module contains more than one
        global plug-in and they share a single activation function, the <tt>id</tt> can be used to
        tell which global is being requested.</dd>
      <dt><tt><br>
        <strong>data</strong></tt></dt>
      <dd>The return value of the global. Fill this in with whatever is appropriate to satisfy the
        global request, or NULL to indicate failure. The value is typically a pointer to static
        data. </dd>
    </dl>
    <p>Global class plug-ins are available in both Modeler and Layout by default. If you don't
    want to run in one of these components, call the <a href="../globals/sysid.html">System ID</a>
    global in your activation function and return <tt>AFUNC_BADAPP</tt> if the <tt>LWSYS_TYPEBITS</tt>
    of the return value don't match a program you will run in. The following fragment will
    allow your global to be activated in Layout and Screamernet, but not in Modeler.</p>
    <pre>   unsigned long sysid, app;

   sysid = ( unsigned long ) global( LWSYSTEMID_GLOBAL,
      GFUSE_TRANSIENT );
   app = sysid &amp; LWSYS_TYPEBITS;
   if ( app != LWSYS_LAYOUT &amp;&amp; app != LWSYS_SCREAMERNET )
      return AFUNC_BADAPP;</pre>
    <p><strong>Example</strong></p>
    <p>The <a href="../../sample/vecmath">vecmath</a> sample is a Global class plug-in that
    provides a library of vector and matrix routines. Information on how to use this library
    in your plug-ins is given in the comments at the top of the source file.</td>
  </tr>
</table>
</body>
</html>
